import Content from '@/sheep/layouts/content.vue';
import { request } from '@/sheep/request';
import { CRUD } from '@/sheep/request/crud';
import { EXPORT } from '@/sheep/request/export';
const route = {
  path: 'orders',
  name: 'supplychian.admin.orders',
  component: Content,
  meta: {
    title: '订单管理',
  },
  children: [
    {
      path: 'orders',
      name: 'supplychian.admin.orders.orders',
      component: () => import('./order/index.vue'),
      meta: {
        title: '商品订单',
      },
    },
    {
      path: 'aftersales',
      name: 'supplychian.admin.supply.aftersales',
      component: () => import('./aftersale/index.vue'),
      meta: {
        title: '供应商管理',
      },
    },
  
  ],
};

const api = {
  order_yzh:{
    orderList: (data) =>
      request({
        url: '/shop/admin/order/order/channelOrderList',
        method: 'GET',
        params:data
      }),
    aftersaleList: (data) =>
      request({
        url: '/shop/admin/order/aftersale/channelOrderList',
        method: 'GET',
        params:data
      }),
      agreeRefund: (id) =>
      request({
        url: `/shop/admin/order/aftersale/agreeRefund/${id}`,
        method: 'GET',
      }),
      refuse: (id,params) =>
      request({
        url: `/shop/admin/order/aftersale/refuse/${id}`,
        method: 'PUT',
        params
      }),
  },
  order_1688:{
    orderList: (data) =>
      request({
        url: '/shop/api/order/tripartiteorder/order_list',
        method: 'GET',
        params:data
      }),
    aftersaleList: (data) =>
      request({
        url: '/shop/admin/order/aftersale/channelOrderList',
        method: 'GET',
        params:data
      }),
      
  },
    order: {
      ...CRUD('shop/admin/order/order', ['list', 'detail', 'edit']),
      orderList: (data) =>
        request({
          url: '/shop/admin/order/order/channelOrderList',
          method: 'GET',
          params:data
        }),
      getType: () =>
        request({
          url: '/shop/admin/order/order/getType',
          method: 'GET',
        }),
      action: (id) =>
        request({
          url: `/shop/admin/order/order/action/${id}`,
          method: 'GET',
        }),
      // 发货
      dispatch: (data) =>
        request({
          url: '/shop/admin/order/order/dispatch',
          method: 'POST',
          data,
        }),
      // 导出
      export: (type, params) => EXPORT(`/shop/admin/order/order/${type}`, params),
      // 上传发货单发货
      dispatchByUpload: (data) =>
        request({
          url: '/shop/admin/order/order/dispatch',
          headers: {
            'Content-Type': 'multipart/form-data',
          },
          method: 'POST',
          data,
        }),
      customDispatch: (data) =>
        request({
          url: '/shop/admin/order/order/customDispatch',
          method: 'POST',
          data,
        }),
      editMemo: (id, data) =>
        request({
          url: `/shop/admin/order/order/editMemo/${id}`,
          method: 'PUT',
          data,
        }),
      applyRefundRefuse: (id) =>
        request({
          url: `/shop/admin/order/order/applyRefundRefuse/${id}`,
          method: 'PUT',
        }),
      fullRefund: (id, data) =>
        request({
          url: `/shop/admin/order/order/fullRefund/${id}`,
          method: 'PUT',
          data,
        }),
      refund: (id, item_id, data) =>
        request({
          url: `/shop/admin/order/order/refund/${id}/${item_id}`,
          method: 'PUT',
          data,
        }),
      updateExpress: (id, params) =>
        request({
          url: `/shop/admin/order/order/updateExpress/${id}`,
          method: 'GET',
          params,
        }),
      changeFee: (id, data) =>
        request({
          url: `/shop/admin/order/order/changeFee/${id}`,
          method: 'PUT',
          data,
        }),
      editConsignee: (id, data) =>
        request({
          url: `/shop/admin/order/order/editConsignee/${id}`,
          method: 'PUT',
          data,
        }),
      offlineRefuse: (id) =>
        request({
          url: `/shop/admin/order/order/offlineRefuse/${id}`,
          method: 'POST',
        }),
      offlineConfirm: (id) =>
        request({
          url: `/shop/admin/order/order/offlineConfirm/${id}`,
          method: 'POST',
        }),
    },
    aftersale: {
      ...CRUD('shop/admin/order/aftersale', ['list', 'detail']),
      channelOrderList: (data) =>
        request({
          url: '/shop/admin/order/aftersale/channelOrderList',
          method: 'GET',
          params:data
        }),
      getType: () =>
        request({
          url: '/shop/admin/order/aftersale/getType',
          method: 'GET',
        }),
      refuse: (id, params) =>
        request({
          url: `/shop/admin/order/aftersale/refuse/${id}`,
          method: 'PUT',
          params,
        }),
      refund: (id, params) =>
        request({
          url: `/shop/admin/order/aftersale/agreeRefund/${id}`,
          method: 'PUT',
          params,
        }),
      completed: (id) =>
        request({
          url: `/shop/admin/order/aftersale/completed/${id}`,
          method: 'PUT',
        }),
      addLog: (id, data) =>
        request({
          url: `/shop/admin/order/aftersale/addLog/${id}`,
          method: 'PUT',
          data,
        }),
    },
    invoice: {
      ...CRUD('shop/admin/order/invoice', ['list']),
      confirm: (id, data) =>
        request({
          url: '/shop/admin/order/invoice/confirm/' + id,
          method: 'PUT',
          data,
        }),
    },
  };

export { route, api };
